package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.ScaleMapper;
import com.wanmait.recruitment.pojo.Scale;
import com.wanmait.recruitment.service.ScaleService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class
ScaleServiceImpl implements ScaleService {
    @Resource
    private ScaleMapper scaleMapper;
    @Override
    public void insert(Scale object) {
        scaleMapper.add(object);

    }

    @Override
    public void delete(Integer id) {
        scaleMapper.delete(id);

    }

    @Override
    public void delete(String ids) {
        scaleMapper.batchDelete(ids);

    }

    @Override
    public void update(Scale object) {
        scaleMapper.update(object);

    }

    @Override
    public Scale findById(Integer id) {
        return null;
    }

    @Override
    @Cacheable("scaleCache")
    public List<Scale> findAll() {
        return scaleMapper.finaAll();
    }

    @Override
    public List<Scale> findAll(Scale object) {
        return null;
    }

    @Override
    public PageInfo<Scale> findPage(int pageNum, int pageSize)
    {
        PageHelper.startPage(pageNum,pageSize);
        List<Scale>scaleList=scaleMapper.finaAll();
        PageInfo<Scale>pageInfo=new PageInfo<>(scaleList);
        return pageInfo;
    }
}
